package com.egao.sszg.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.sszg.biz.BillBiz;
import com.egao.sszg.entity.Bill;
import com.egao.sszg.service.BillService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

//import com.egao.oa.mapper.BillMapper;

/**
 * 运单服务实现类
 * @author : Doman
 * @date : 2021-08-19 09:43:36
 * @version ：1.0
 */
@Service
public class BillServiceImpl /*extends ServiceImpl<BillMapper, Bill> */implements BillService {

	@Autowired
	private BillBiz billBiz;

    /**
    @Override
    public PageResult<Bill> listPage(PageParam<Bill> page) {
        List<Bill> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Bill> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Bill bill, User loginUser)  throws Exception{
        return billBiz.list(page,bill,loginUser);
    }

    @Override
    public List<Bill> list(Bill bill, User loginUser) {
        return billBiz.list(bill,loginUser);
    }

    @Override
    public JsonResult getById(Bill bill) {
        return JsonResult.ok().setData(billBiz.getById(bill));
    }

    @Transactional
    @Override
    public JsonResult save(Bill bill, User loginUser) {
        if (billBiz.save(bill, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(Bill bill, User loginUser) {
        if (billBiz.update(bill, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(Bill bill, User loginUser) {
        if (billBiz.remove(bill, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
